/*
****************************************************************************************************************
*= = 版权信息：Copyright (C) 356 - 999. Ombres Industry Empiral. All rights reserved.
*= = 文件名称：Hubris.h
*= = 功能描述：风之谷数据库管理声明主文件
*= = 编写人员：Carlyon W. Tung
****************************************************************************************************************
*/


#ifndef __HUBRIS_H__
#define __HUBRIS_H__


#include <cstdio>

#include <libpq-fe.h>

#include <Ginkgo.h>
#include <Hyacinth.h>


#if defined(HUBRIS_LIBRARY)
#define HUBRIS_LIBRARY_INTERFACE O_DECL_EXPORT
#else
#define HUBRIS_LIBRARY_INTERFACE O_DECL_IMPORT
#endif

namespace Hubris {
    //
}

using namespace Hubris;

class HUBRIS_LIBRARY_INTERFACE OHubris : public OObject
{
public:
    OHubris();
    ~OHubris();

public:
    // TODO

private:
    // TODO

public:
    // TODO

private:
    // TODO
};

class HUBRIS_LIBRARY_INTERFACE OPostgreSQL : public OHubris
{
public:
    OPostgreSQL();
    ~OPostgreSQL();

public:
    int ConnectDatabase(std::string& errmsg);
    int CloseDatabase(void);
    int CreateDatabase(void);
    int InsertMeasureItem(std::string& table, std::string& measure, double dmidv, std::string& variant);
    bool CreateTable(const std::string& tableName);
    bool CreateSuperTable(const std::string& tableName);
    int SwitchDatabase(void);
    int InitialTimescaleDB(void);
    bool TableIsExists(const std::string& tableName);

    void SetHubrisXml(const std::string& HubrisXml);

private:
    bool CreateSequence(void);
    void InitialPostgreSQLFromGinkgo(void);

public:
    OGinkgoPostgreSQL m_ginkgo_postgres;

    std::string m_HubrisXml;

private:
    PGconn* m_psql_connect;
    PGresult* m_psql_result;

    std::string m_hostaddress;
    std::string m_port;
    std::string m_dbname;
    std::string m_user;
    std::string m_password;
    std::string m_version;
};

class HUBRIS_LIBRARY_INTERFACE OTimescaleDB : public OPostgreSQL
{
public:
    OTimescaleDB();
    ~OTimescaleDB();

public:
    // TODO

private:
    // TODO

public:
    // TODO

private:
    // TODO
};


#endif // End of __HUBRIS_H__


/*
****************************************************************************************************************
*= = 文件结束
****************************************************************************************************************
*/


